<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
<script>
	var str = 'abcdefjo';
	alert(str.substr(0,3));		//	abc

		var str = 'abcdefjo';
	alert(str.substr(0,4));		//	abcd
</script>
</body>
</html>